package com.es.servlet;

import com.es.service.StudentService;
import com.es.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 描述:
 * es-jsp-
 *
 * @author Derek
 * 创建时间：2022-04-25 12:04
 */
@WebServlet("/delete")
public class DeleteServlet extends HttpServlet {
    StudentService service = new StudentServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("id"));
        boolean flag = service.delete(id);
        String msg = "删除失败";
        if(flag){
            System.out.println("删除成功");
            msg = "删除成功";
        }
        //
        request.getSession().setAttribute("msg", msg);
        response.sendRedirect("list");
    }
}
